<template>
  <div class="approval-center-page">
    <div class="search-wrapper">
      <super-search :search-form="searchForm" :search-item-config="searchItemList" @search="searchHandle"></super-search>
    </div>
    <div class="content-wrapper">
      <a-tabs v-model:activeKey="activeKey" @change="getData()">
        <a-tab-pane :key="0" :tab="`未结案`"></a-tab-pane>
        <a-tab-pane :key="1" :tab="`已结案`"></a-tab-pane>
      </a-tabs>
      <super-table
        :height="tableHeight"
        ref="tableRef"
        v-model:page="searchForm.pageNum"
        v-model:limit="searchForm.pageSize"
        :loading="loading"
        :data="tableData"
        :total="searchForm.total"
        :column="tableColumn"
        @change-page="getData"
      >
        <!-- <template #tool>
          <a-button type="primary" @click="addHandle">新增</a-button>
        </template> -->

        <template #eee="{ row }">
          {{ "个人:" + row.bizProportionPrice + "元," + "公司:" + row.companyProportionPrice + "元" }}
        </template>
        <template #state="{ row }">
          <a-tag v-if="row.state === 0" color="#108ee9">待审批</a-tag>
          <a-tag v-if="row.state === 1" color="#2db7f5">审批中</a-tag>
          <a-tag v-if="row.state === 2" color="#cd201f">审批驳回</a-tag>
          <a-tag v-if="row.state === 3" color="#8A1028">待确认</a-tag>
          <a-tag v-if="row.state === 4" color="#67c23a">审批完成</a-tag>
        </template>
        <template #action="{ row }">
          <a-button type="link" @click="checkProblemHandle(row)">查看</a-button>
          <a-button type="link" v-if="activeKey === 0" @click="closeCaseHandle(row)">结案</a-button>
        </template>
      </super-table>
    </div>
    <a-modal v-model:visible="dialogOpts.visible" :maskClosable="false" :keyboard="false" :closable="false" :footer="null" :title="dialogOpts.title" :width="dialogOpts.width">
      <component v-model:visible="dialogOpts.visible" :is="dialogOpts.component" :type="dialogOpts.type" :pass-data="dialogOpts.passData" @submit="dialogSubmitHandle"></component>
    </a-modal>

    <!-- 抽屉 -->
    <a-drawer class="custom-drawer" v-model:visible="drawerOpts.visible" :title="drawerOpts.title" :closable="true" @close="drawerOpts.visible = false" :width="drawerOpts.width" placement="right">
      <component
        v-model:visible="drawerOpts.visible"
        :activeKey="activeKey"
        :is="drawerOpts.component"
        :type="drawerOpts.type"
        :pass-data="drawerOpts.passData"
        @submit="drawerSubmitHandle"
      ></component>
    </a-drawer>
  </div>
</template>

<script lang="ts">
import CheckProblem from "./components/checkProblem/index.vue";

export default {
  name: "FinanceClosing",
  components: {
    CheckProblem
  }
};
</script>
<script lang="ts" setup>
import TableHeightHook from "@/hook/tableHeightHook";
import ModalHook from "@/hook/modalHook";
import { searchItemList, tableColumn } from "./data";
import InitHook from "./composables/initHook";
import OperationHook from "./composables/operationHook";
const { tableHeight, loading } = TableHeightHook(50);
const { searchForm, tableData, dialogOpts, activeKey, drawerOpts, tableRef } = InitHook();
const { searchHandle, getData, checkProblemHandle, closeCaseHandle } = OperationHook({ searchForm, tableData, loading, drawerOpts, activeKey });
const { dialogSubmitHandle, drawerSubmitHandle } = ModalHook({
  dialogOpts,
  drawerOpts,
  callBack: getData
});
getData();
</script>
<style lang="stylus" scoped></style>
